<?php include './application/views/common/header.php'; ?>
<table width="90%" cellspacing="0" cellpadding="0" border="0" class="user_table" style="width:1000px;margin:50px auto;">
	<tr>
		<td valign="top" class="user_table_td"><?php include './application/views/common/user_left.php'; ?></td>
		<!-- Left End -->
		<td valign="top">

<div class="user_con_tab">
  <ul>
<!--    <li><a href="/user/pwd/index.html">登陆密码</a></li>-->
<!--    <li class="current7"><a href="/user/paypwd/index.html">交易密码</a></li>-->
    <!-- <li><a href="">密码保护</a></li> -->
  </ul>
</div>
<!-- User_List_Title End -->

<div class="user_list_con">

		<div class="user_right_border">
			<p>密码找回</p>
		</div>
<input type="radio" name="type" checked id="email_class">邮箱
<input type="radio" name="type" id="phone_class">手机
<form id="my_form">
    <input type="hidden" name="act" value="mail" id="type">
<div class="email_type type">

		<div class="user_right_border">
			<div class="l">您的邮箱：</div>
			<div class="c">
				<?php echo $user['email']; ?>
			</div>
		</div>

		<div class="user_right_border">
			<div class="l">验证码：</div>
			<div class="c">

                            <div style="float: left;"><input type="text" class="input" id="captcha" name="captcha" style="width:45px;" maxlength="4"></div>
				<div style="float: left;margin-left: 10px;"><img src="/yanzheng/index/" id="imgCode" onclick="changeImage();" style="border:0;padding:0px;cursor:pointer;"/></div>

			</div>
		</div>
</div>
    <div class="phone_type type" style="display: none;">
        <div class="user_right_border">
            <div class="l">您的手机号码：</div>
            <input type="hidden" id="phone" value="<?php echo $user['phone']; ?>">
            <div class="c">
                <?php echo $user['phone']; ?>
            </div>
        </div>

        <div class="user_right_border">
            <div class="l">验证码：</div>
            <div class="c">
                <div style="float: left;"><input type="text" class="input" id="captcha1" name="captcha1" style="width:45px;" maxlength="6"></div>
                &nbsp;&nbsp;&nbsp;<a href="javascript:;" onclick="phoneSubmit(12);" style="background: #111;" id="phone_code"> 获取验证码</a>
            </div>
        </div>
    </div>
    <div class="user_right_border">
			<div class="l"></div>
			<div class="c">
                            <input class="little_button" type="button" size="30" value="确认提交" onclick="toSubmit();">
			</div>
		</div>
</form>
<script>
    $(function(){
        $("#email_class").click(function(){
            if($(this).attr('checked')){
                $(".type").hide();
                $(".email_type").show();
                $("#type").val('mail');
            }
        });
        $("#phone_class").click(function(){
            if($(this).attr('checked')){
                $(".type").hide();
                $(".phone_type").show();
                $("#type").val('phone');
            }
        });
    });
    function phone_countdown(){
        var count = 60;
        var countdown = setInterval(CountDown, 1000);

        function CountDown() {
            $("#phone_code").html('<font style="color:#000000;">'+count+"</font>秒后重试");
            if (count == 0) {
                $("#phone_code").html('获取验证码');
                clearInterval(countdown);
            }
            count--;
        }

    }

    function toSubmit(){
	var options = {
		url : '/user/find',
		clearForm :true,
		resetForm :true,
		beforeSubmit:  checkForm,
		dataType: "json",
		type:"post",
		success : function(ret) {
			if(ret.msg==''){
				$('#dialog').dialog({
					modal:true,
					title:'系统提示',
					buttons:{"确定":function(){$(this).dialog("close");}},
					close: function() {
						if(ret.url==''){
							window.location.reload();
						}else{
							window.location=ret.url;
						}
					}
				});
				$("#msg").html("操作成功");
			}else{
				$('#dialog').dialog({
					modal:true,
					title:'系统提示',
					buttons:{"确定":function(){$(this).dialog("close");}}
				});
				$("#msg").html(ret.msg);
			}
		}
	};
	$("#my_form").ajaxSubmit(options);
	return false;
}

function checkForm(){
	var err = '';


	if(err==''){
		return true;
	}else{
		$('#dialog').dialog({
			modal:true,
			title:'系统提示',
			buttons:{"确定":function(){$(this).dialog("close");}},
			close: function() {
				$("#my_form").resetForm();
			}
		});
		$("#msg").html(err);
		return false;
	}
}
function phoneSubmit($id){
    if($('#phone').val()=='' || $("#phone").val() == "请输入手机号码"){
        $('#dialog').dialog({
            modal:true, //蒙层（弹出会影响页面大小）
            title:'系统提示',
            buttons:{"确定":function(){$(this).dialog("close");}},
            close: function() {
            }
        });
        $("#msg").html("手机号码未设置");
        return false;
    }else{
        $.ajax({
            type: "post",
            url: "/reg/apply_phone/"+$id,
            data: "phone="+$("#phone").val(),
            success: function(ret){
                //$("#phone_code").html(ret.msg);
                if(ret.info == 1){
                    phone_countdown();
                }else{
                    $("#msg").html(ret.msg);
                }


            },
            dataType: "json"
        });
    }

}
</script>
</div>
<!-- User_List_Con End -->
</td>
	</tr>
</table>

<?php include './application/views/common/footer.php'; ?>